capture log close
set more off
global rep "/Users/tdemont/ownCloud/Documents/Academic/LSMS_India"

use "$rep\SHG_school_data_pub_EDCC.dta", clear


global Veduc primaryschool_village middleschool_village medsecschooldist  kmhaat_village road_village nbhh_avg  proplandless_01 propillitpop_01 propfillitpop_01 propSCpop_01
global Vhh precdefsdjunsep_2 precdefsdjunsep_1 SC ST hindu BPL  headage motherage  headnoschool  headmorethanprim  motheranyschool noland smallland bigland nb0_5 nbprimschoolagegirl nbprimschoolageboy nbmidsecschoolageboy nbmidsecschoolagegirl   nbmajor  


* Table 3 enrollment
areg enrolled membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store enrol_cont
areg enrolled  membervilXr2 membervilXr3  age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store enrol_vfe 
areg enrolled membervillage membervilXr2 membervilXr3 age1415 age1617  female femaleXmembervil femaleXmvr2 femaleXmvr3 headschild   eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3 $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store enrol_contF
areg enrolled  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild   eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue) cluster(hhid) 
estimates store enrol_vfeF
areg enrolled  membervilXr2 membervilXr3  age   female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<15, a(revenue)  cluster(hhid) 
estimates store enrol1214_vfe 
areg enrolled  membervilXr2 membervilXr3  age   female femaleXmembervil femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<15, a(revenue)  cluster(hhid) 
estimates store enrol1214_vfeF
areg enrolled  membervilXr2 membervilXr3  age   female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>=15&age<18, a(revenue)  cluster(hhid) 
estimates store enrol1517_vfe 
areg enrolled  membervilXr2 membervilXr3  age   female femaleXmembervil femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>=15&age<18, a(revenue)  cluster(hhid) 
estimates store enrol1517_vfeF 


* Table 4 Drop out

cap drop co911r1enrolled
cap drop co712r1enrolled
bysort hhid mem_id: egen co68r1enrolled= total(age >6 & age <9 & round==1&enrolled==1) /* 8-10 and 11-13: entry into lower sec last round */
bysort hhid mem_id: egen co69r1enrolled= total(age >6 & age <=9 & round==1&enrolled==1) /* 8-10 and 11-13: entry into lower sec last round */
bysort hhid mem_id: egen co911r1enrolled= total(age >8 & age <12 & round==1&enrolled==1)
bysort hhid mem_id: egen co712r1enrolled= total(age >6 & age <=12 & round==1&enrolled==1) /* 9-14 and 12-17 */

areg enrolled  membervillage membervilXr3  age1011 age1213 age1415 age1617  female headschild eldestchild eldestsamesex   round3 $Vhh $Veduc [pw=samplingweight] if co712r1enrolled==1&round>1, a(district) cluster(hhid) 
estimates store drop712_cont
areg enrolled   membervilXr3  age1011 age1213 age1415 age1617  female headschild eldestchild  eldestsamesex  round3 $Vhh [pw=samplingweight] if co712r1enrolled==1&round>1, a(revenue) cluster(hhid) 
estimates store drop712_vfe
areg enrolled  membervillage membervilXr3   age1415 age1617  female headschild eldestchild    round3 $Vhh $Veduc [pw=samplingweight] if enrolled_1==1&round>1&age>12&((round==3&age<18)|(round==2&age<15)), a(district) cluster(hhid) 
estimates store enrol1sec_cont
areg enrolled  membervilXr3   age1415 age1617  female headschild eldestchild    round3 $Vhh [pw=samplingweight] if enrolled_1==1&round>1&age>12&((round==3&age<18)|(round==2&age<15)), a(revenue) cluster(hhid) 
estimates store enrol1sec_vfe

areg enrolled membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if highestgrade2>=5&highestgrade2<.&age>12&age<18, a(district) cluster(hhid) 
estimates store enrolprim_cont
areg enrolled  membervilXr2 membervilXr3  age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if highestgrade2>=5&highestgrade2<.&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store enrolprim_vfe 


* Table 5 Grade for age

gen co121709=(round==3&age>12&age<18)|(round==2&age>9&age<15)|(round==1&age>7&age<13)
cap drop co121409
cap drop co151709
gen co121409=(round==3&age>12&age<15)|(round==2&age>9&age<12)|(round==1&age>7&age<10)
gen co151709=(round==3&age>=15&age<18)|(round==2&age>=12&age<15)|(round==1&age>=10&age<13)

areg schoolforage membervillage membervilXr2 membervilXr3 age89 age1011 age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>6&age<18, a(district) cluster(hhid) 
estimates store sfa617_cont
areg schoolforage  membervilXr2 membervilXr3  age89 age1011 age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>6&age<18, a(revenue)  cluster(hhid) 
estimates store sfa617_vfe
areg schoolforage membervillage membervilXr2 membervilXr3 age89 age1011 age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if enrolled==1&age>6&age<18, a(district) cluster(hhid) 
estimates store sfa617_enrol_cont
areg schoolforage  membervilXr2 membervilXr3  age89 age1011 age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if enrolled==1&age>6&age<18, a(revenue)  cluster(hhid) 
estimates store sfa617_enrol_vfe
areg schoolforage  membervillage membervilXr2 membervilXr3 age67 age89 age1011  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh $Veduc [pw=samplingweight] if age>6&age<=12, a(district)  cluster(hhid) 
estimates store sfa611_cont
areg schoolforage  membervilXr2 membervilXr3 age67 age89 age1011  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>6&age<=12, a(revenue)  cluster(hhid) 
estimates store sfa611_vfe
areg schoolforage  membervilXr2 membervilXr3  age89 age1011  age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if co121709==1, a(revenue)  cluster(hhid) 
estimates store sfaco1217_vfe
areg schoolforage  membervilXr2 membervilXr3  age89 age1011 age1213 age1415   female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if co121409==1, a(revenue)  cluster(hhid) 
estimates store sfaco1214_vfe
areg schoolforage  membervilXr2 membervilXr3    age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if co151709==1, a(revenue)  cluster(hhid) 
estimates store sfaco1517_vfe


* Table 6 Additional education outcomes

areg enrolgrade6up membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store g6up_cont
areg enrolgrade6up  membervilXr2 membervilXr3  age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store g6up_vfe
areg enrolgrade9up membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store g9up_cont
areg enrolgrade9up  membervilXr2 membervilXr3  age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store g9up_vfe

areg lschoolexp1 membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store lexp_itt_cont
areg lschoolexp1  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store lexp_itt_vfe

areg anyschoolexp200 membervillage membervilXr2 membervilXr3 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store any200_itt_cont
areg anyschoolexp200  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store any200_itt_vfe

gen schoolattendbis=schoolattend
replace schoolattendbis=5 if schoolattendbis==6 /* some schools have class on Saturdays, some don't */

areg schoolattendbis membervillage membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex round2 round3 $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store attend_itt_cont
areg schoolattendbis  membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store attend_itt_vfe


* Table 7 Child labor

areg childweekwork  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store work_vfe
areg childweekwork  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild   eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue) cluster(hhid) 
estimates store work_vfeF
areg childanywork  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anywork_vfe
areg childanywork  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anywork_vfeF
areg childweekwork  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if childweekwork>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condwork_vfe
areg childweekwork  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3  $Vhh [pw=samplingweight] if childweekwork>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condwork_vfeF

areg childweekworkout  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store workout_vfe
areg childweekworkout  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild   eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue) cluster(hhid) 
estimates store workout_vfeF
areg childanyworkout  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anyworkout_vfe
areg childanyworkout  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anyworkout_vfeF
areg childweekworkout  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if childweekworkout>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condworkout_vfe
areg childweekworkout  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if childweekworkout>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condworkout_vfeF

areg childweekworkhh  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store workhh_vfe
areg childweekworkhh  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild   eldestchild eldestsamesex  round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue) cluster(hhid) 
estimates store workhh_vfeF
areg childanyworkhh  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anyworkhh_vfe
areg childanyworkhh  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store anyworkhh_vfeF
areg childweekworkhh  membervilXr2 membervilXr3 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3  $Vhh [pw=samplingweight] if childweekworkhh>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condworkhh_vfe
areg childweekworkhh  membervilXr2 membervilXr3 age1415 age1617  female  femaleXmvr2 femaleXmvr3 headschild  eldestchild eldestsamesex   round2 round3 femaleXr2 femaleXr3  $Vhh [pw=samplingweight] if childweekworkhh>0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store condworkhh_vfeF

* Table 8 Correlation matrix labor enrollment

pwcorr enrolled childweekwork childanywork childweekworkout childanyworkout childweekworkhh childanyworkhh if sex==1&age>12&age<18,sig obs
pwcorr enrolled childweekwork childanywork childweekworkout childanyworkout childweekworkhh childanyworkhh if sex==2&age>12&age<18,sig obs


* Table 9 Credit

areg enrolled membervillage membervilXr2 membervilXr3 borrpos1y age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store borrpos_cont
areg enrolled  membervilXr2 membervilXr3 borrpos1y age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store borrpos_vfe 
areg enrolled membervillage membervilXr2 membervilXr3 borrpos1y lloan1y1 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district) cluster(hhid) 
estimates store borrcredit_cont
areg enrolled  membervilXr2 membervilXr3 borrpos1y lloan1y1 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store borrcredit_vfe 


* Table 10 Peer effects enrollment

areg enrolled  propothmembers121709 memberhh membervillage membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district)  cluster(hhid) 
estimates store prop121709
areg enrolled  propothmembers121709 memberhh membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store prop121709_vfe
areg enrolled  propothmembers182309  memberhh membervillage membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district)  cluster(hhid) 
estimates store prop1823
areg enrolled  propothmembers182309  memberhh membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store prop1823_vfe
areg enrolled  propothmembers121709 propothmembers182309  memberhh membervillage membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh $Veduc [pw=samplingweight] if age>12&age<18, a(district)  cluster(hhid) 
estimates store prop12171823
areg enrolled  propothmembers121709 propothmembers182309  memberhh membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh [pw=samplingweight] if age>12&age<18, a(revenue)  cluster(hhid) 
estimates store prop12171823_vfe
areg enrolled  propothmembers121709  memberhh membervillage membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh $Veduc [pw=samplingweight] if headmorethanprim==0&age>12&age<18, a(district)  cluster(hhid) 
estimates store prop121709noexp
areg enrolled  propothmembers121709  memberhh membervilXr2 membervilXr3 age1415 age1617  female  headschild eldestchild eldestsamesex  round2 round3 $Vhh [pw=samplingweight] if headmorethanprim==0&age>12&age<18, a(revenue)  cluster(hhid) 
estimates store prop121709noexp_vfe


* Table 11 Peer effects grade for age

gen propothmembers61709=propothmembers61109+ propothmembers121709
gen co121809=(round==3&age>12&age<18)|(round==2&age>9&age<15)|(round==1&age>7&age<13)

areg schoolforage propothmembers61709 memberhh membervillage membervilXr2 membervilXr3 age89 age1011 age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>6&age<18, a(district) cluster(hhid) 
estimates store sfa617_cont
areg schoolforage  propothmembers61709 memberhh membervilXr2 membervilXr3  age89 age1011 age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>6&age<18, a(revenue)  cluster(hhid) 
estimates store sfa617_vfe
areg schoolforage propothmembers182309 memberhh membervillage membervilXr2 membervilXr3 age89 age1011 age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if age>6&age<18, a(district) cluster(hhid) 
estimates store sfa1823_cont
areg schoolforage  propothmembers182309 memberhh membervilXr2 membervilXr3  age89 age1011 age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if age>6&age<18, a(revenue)  cluster(hhid) 
estimates store sfa1823_vfe
areg schoolforage propothmembers61709 memberhh membervillage membervilXr2 membervilXr3 age89 age1011 age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if enrolled==1&age>6&age<18, a(district) cluster(hhid) 
estimates store sfa617_enrol_cont
areg schoolforage  propothmembers61709 memberhh membervilXr2 membervilXr3  age89 age1011 age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if enrolled==1&age>6&age<18, a(revenue)  cluster(hhid) 
estimates store sfa617_enrol_vfe
areg schoolforage propothmembers121709 memberhh membervillage membervilXr2 membervilXr3 age89 age1011  age1213 age1415 age1617  female headschild   eldestchild eldestsamesex  round2 round3  $Vhh $Veduc [pw=samplingweight] if co121809==1, a(district) cluster(hhid) 
estimates store sfaco1218_cont
areg schoolforage  propothmembers121709 memberhh membervilXr2 membervilXr3  age89 age1011  age1213 age1415 age1617  female headschild  eldestchild eldestsamesex   round2 round3 $Vhh [pw=samplingweight] if co121809==1, a(revenue)  cluster(hhid) 
estimates store sfaco1218_vfe

